#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{freopen("arena.in","r",stdin);
freopen("arena.out","w",stdout);
    srand(time(0));
int n,m,x,t;cin>>n>>m;
for(int i=1;i<=n;++i)cin>>x;
for(int j=1;j<=n;++j)cin>>x;
int a=1;while(a<=n)a*=2;
for(int i=1;i<=a-n;++i)
{
string s;cin>>s;

}
cin>>t;
while(t--)cout<<rand()%m*m<<endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
}
